<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get column information from a result and return as an object</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.fbsql-fetch-assoc.html">fbsql_fetch_assoc</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.fbsql-fetch-lengths.html">fbsql_fetch_lengths</a></div>
 <div class="up"><a href="ref.fbsql.html">FrontBase 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.fbsql-fetch-field" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">fbsql_fetch_field</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.6, PHP 5)</p><p class="refpurpose"><span class="refname">fbsql_fetch_field</span> &mdash; <span class="dc-title">Get column information from a result and return as an object</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.fbsql-fetch-field-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">object</span> <span class="methodname"><strong>fbsql_fetch_field</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$result</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$field_offset</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   Used in order to obtain information about fields in a certain query result.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.fbsql-fetch-field-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    <dt>
<em><code class="parameter">
result</code></em></dt>
<dd>
<p class="para">由 <span class="function"><a href="function.fbsql-query.html" class="function">fbsql_query()</a></span>
或 <span class="function"><a href="function.fbsql-db-query.html" class="function">fbsql_db_query()</a></span> 返回的结果标识符。</p></dd>

    
     <dt>
<em><code class="parameter">field_offset</code></em></dt>

     <dd>

      <p class="para">
       The numerical offset of the field. The field index starts at 0.
       If not specified, the next field that wasn&#039;t yet retrieved by 
       <span class="function"><strong>fbsql_fetch_field()</strong></span> is retrieved.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.fbsql-fetch-field-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an object containing field information, or <strong><code>FALSE</code></strong> on errors.
  </p>
  <p class="para">
   The properties of the object are:
   <ul class="itemizedlist">
    <li class="listitem">
     <span class="simpara">
      name - column name
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      table - name of the table the column belongs to
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      max_length - maximum length of the column
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      not_null - 1 if the column cannot be <strong><code>NULL</code></strong>
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      type - the type of the column
     </span>
    </li>
   </ul>
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.fbsql-fetch-field-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-1099">
    <p><strong>Example #1 <span class="function"><strong>fbsql_fetch_field()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />fbsql_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$host</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$user</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$password</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;connect"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fbsql_db_query</span><span style="color: #007700">(</span><span style="color: #DD0000">"database"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"select&nbsp;*&nbsp;from&nbsp;table"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Query&nbsp;failed"</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">#&nbsp;get&nbsp;column&nbsp;metadata<br /></span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />while&nbsp;(</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">fbsql_num_fields</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Information&nbsp;for&nbsp;column&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #DD0000">:&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$meta&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fbsql_fetch_field</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #0000BB">$meta</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"No&nbsp;information&nbsp;available&lt;br&nbsp;/&gt;\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"&lt;pre&gt;<br />max_length:&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$meta</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">max_length</span><span style="color: #DD0000"><br />name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$meta</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">name</span><span style="color: #DD0000"><br />not_null:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$meta</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">not_null</span><span style="color: #DD0000"><br />table:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$meta</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">table</span><span style="color: #DD0000"><br />type:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$meta</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">type</span><span style="color: #DD0000"><br />&lt;/pre&gt;"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++;<br />}<br /></span><span style="color: #0000BB">fbsql_free_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$result</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.fbsql-fetch-field-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.fbsql-field-seek.html" class="function" rel="rdfs-seeAlso">fbsql_field_seek()</a> - Set result pointer to a specified field offset</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.fbsql-fetch-assoc.html">fbsql_fetch_assoc</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.fbsql-fetch-lengths.html">fbsql_fetch_lengths</a></div>
 <div class="up"><a href="ref.fbsql.html">FrontBase 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
